﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.ProcessManagement;
using Digitalmes.Model.EquipmentManagement;

namespace Digitalmes.Model.ProcessManagement
{
    /// <summary>
    /// ProcessRouteItem
    /// </summary>
	[Table("ProcessRoutetem")]

    [Display(Name = "_Model.ProcessRouteItem")]
    public class ProcessRouteItem : BasePoco,IPersistPoco,ITenant
    {
        [Display(Name = "_Model._ProcessRouteItem._Routie")]
        [Comment("工艺路线")]
        public ProcessRoute Routie { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._Routie")]
        [Comment("工艺路线")]
        public long? RoutieId { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._OpCode")]
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("工序编号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string OpCode { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._StdOpDuration")]
        [Comment("标准加工工时(秒)")]      
        [Precision(18, 2)]
        public decimal? StdOpDuration { get; set; } = 0;
        [Display(Name = "_Model._ProcessRouteItem._StdPrepDuration")]
        [Comment("标准准备工时(秒)")]
        [Precision(18, 2)]
        public decimal? StdPrepDuration { get; set; } = 0;
        [Display(Name = "_Model._ProcessRouteItem._Pos")]
        [Comment("工艺位置")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? Pos { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._PolicyCheckPrevProc")]
        [Comment("校验上一工序动作")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public PolicyCheckPrevProcEnum? PolicyCheckPrevProc { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._PolicyCheckProcBom")]
        [Comment("校验生产BOM动作")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public PolicyCheckProcBomEnum? PolicyCheckProcBom { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._PolicyCheckProcess")]
        [Comment("工艺校验策略")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public PolicyCheckProcessEnum? PolicyCheckProcess { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._CtlAttr")]
        [Comment("工艺管控属性")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public ProcCtlAttrEnum? CtlAttr { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._ErpOpCode")]
        [Comment("工厂工序")]
        public string ErpOpCode { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._Etag")]
        [Comment("处理标记")]
        public string Etag { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._Active")]
        [Comment("激活")]

        public bool Active { get; set; } = false;

        [Display(Name = "_Model._ProcessRouteItem._Aux_1")]
        public string Aux_1 { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._Aux_2")]
        public string Aux_2 { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._OpName")]
        [Comment("工序名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string OpName { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._GroupCode")]
        [Comment("工序组")]
        public string GroupCode { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._EquipmentId")]
        [Comment("关联设备")]
        public long? EquipmentId { get; set; }

        public Equipment Equipment { get; set; }


        [Display(Name = "_Model._ProcessRouteItem._EquipmentCode")]
        [Comment("设备编号")]
        public string EquipmentCode { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._OpType")]
        [Comment("工序类型")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public OpTypeEnum? OpType { get; set; }
        [Key]
        [Display(Name = "_Model._ProcessRouteItem._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._ProcessParameter._Op")]
        [InverseProperty("Op")]
        public List<ProcessParameter> ProcessParameter_Op { get; set; }
        [Display(Name = "_Model._ProcessResults._Op")]
        [InverseProperty("Op")]
        public List<ProcessResults> ProcessResults_Op { get; set; }
        [Display(Name = "_Model._ProcessRouteItem._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
